#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn=10010;
int main()
{
	int n,s,a[maxn];
	scanf("%d%d",&n,&s);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int l=0,r=0,ans=maxn,sum=0;
	while(1){
		while(sum<s&&r<n)
			sum+=a[r++];
		if(sum<s) break;
		ans=min(ans,r-l);
		sum-=a[l++];
	}
	if(ans==maxn)
		printf("-1");
	else
		printf("%d",ans);
	return 0;
}
